<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="机器型号" prop="machinetype">
        <el-input
          v-model="queryParams.machinetype"
          placeholder="请输入机器型号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="并缸轴数" prop="cylindernumber">
        <el-input
          v-model="queryParams.cylindernumber"
          placeholder="请输入并缸轴数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="织轴开档" prop="beamopening">
        <el-input
          v-model="queryParams.beamopening"
          placeholder="请输入织轴开档"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="墨印长度" prop="inklength">
        <el-input
          v-model="queryParams.inklength"
          placeholder="请输入墨印长度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="墨印颜色" prop="inkcolor">
        <el-input
          v-model="queryParams.inkcolor"
          placeholder="请输入墨印颜色"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="后上蜡" prop="waxing">
        <el-input
          v-model="queryParams.waxing"
          placeholder="请输入后上蜡"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="上浆率" prop="sizingpersent">
        <el-input
          v-model="queryParams.sizingpersent"
          placeholder="请输入上浆率"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="回潮率" prop="moistureregain">
        <el-input
          v-model="queryParams.moistureregain"
          placeholder="请输入回潮率"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伸长率" prop="elongation">
        <el-input
          v-model="queryParams.elongation"
          placeholder="请输入伸长率"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="浆槽温度" prop="temperature">
        <el-input
          v-model="queryParams.temperature"
          placeholder="请输入浆槽温度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="浆槽粘度" prop="viscosity">
        <el-input
          v-model="queryParams.viscosity"
          placeholder="请输入浆槽粘度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="浆槽PH值" prop="ph">
        <el-input
          v-model="queryParams.ph"
          placeholder="请输入浆槽PH值"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卷绕线速度" prop="windingspeed">
        <el-input
          v-model="queryParams.windingspeed"
          placeholder="请输入卷绕线速度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="张力调节" prop="tensionadjust">
        <el-input
          v-model="queryParams.tensionadjust"
          placeholder="请输入张力调节"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="压浆辊压力" prop="force">
        <el-input
          v-model="queryParams.force"
          placeholder="请输入压浆辊压力"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预烘温度" prop="pretemp">
        <el-input
          v-model="queryParams.pretemp"
          placeholder="请输入预烘温度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="烘燥温度" prop="dryingtemp">
        <el-input
          v-model="queryParams.dryingtemp"
          placeholder="请输入烘燥温度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['gongyi:gy_process:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['gongyi:gy_process:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['gongyi:gy_process:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['gongyi:gy_process:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="gy_processList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" />
      <el-table-column label="机器型号" align="center" prop="machinetype" />
      <el-table-column label="并缸轴数" align="center" prop="cylindernumber" />
      <el-table-column label="织轴开档" align="center" prop="beamopening" />
      <el-table-column label="墨印长度" align="center" prop="inklength" />
      <el-table-column label="墨印颜色" align="center" prop="inkcolor" />
      <el-table-column label="后上蜡" align="center" prop="waxing" />
      <el-table-column label="上浆率" align="center" prop="sizingpersent" />
      <el-table-column label="回潮率" align="center" prop="moistureregain" />
      <el-table-column label="伸长率" align="center" prop="elongation" />
      <el-table-column label="浆槽温度" align="center" prop="temperature" />
      <el-table-column label="浆槽粘度" align="center" prop="viscosity" />
      <el-table-column label="浆槽PH值" align="center" prop="ph" />
      <el-table-column label="卷绕线速度" align="center" prop="windingspeed" />
      <el-table-column label="张力调节" align="center" prop="tensionadjust" />
      <el-table-column label="压浆辊压力" align="center" prop="force" />
      <el-table-column label="预烘温度" align="center" prop="pretemp" />
      <el-table-column label="烘燥温度" align="center" prop="dryingtemp" />
      <el-table-column label="要求" align="center" prop="request" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['gongyi:gy_process:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['gongyi:gy_process:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改工艺设计工艺表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="机器型号" prop="machinetype">
          <el-input v-model="form.machinetype" placeholder="请输入机器型号" />
        </el-form-item>
        <el-form-item label="并缸轴数" prop="cylindernumber">
          <el-input v-model="form.cylindernumber" placeholder="请输入并缸轴数" />
        </el-form-item>
        <el-form-item label="织轴开档" prop="beamopening">
          <el-input v-model="form.beamopening" placeholder="请输入织轴开档" />
        </el-form-item>
        <el-form-item label="墨印长度" prop="inklength">
          <el-input v-model="form.inklength" placeholder="请输入墨印长度" />
        </el-form-item>
        <el-form-item label="墨印颜色" prop="inkcolor">
          <el-input v-model="form.inkcolor" placeholder="请输入墨印颜色" />
        </el-form-item>
        <el-form-item label="后上蜡" prop="waxing">
          <el-input v-model="form.waxing" placeholder="请输入后上蜡" />
        </el-form-item>
        <el-form-item label="上浆率" prop="sizingpersent">
          <el-input v-model="form.sizingpersent" placeholder="请输入上浆率" />
        </el-form-item>
        <el-form-item label="回潮率" prop="moistureregain">
          <el-input v-model="form.moistureregain" placeholder="请输入回潮率" />
        </el-form-item>
        <el-form-item label="伸长率" prop="elongation">
          <el-input v-model="form.elongation" placeholder="请输入伸长率" />
        </el-form-item>
        <el-form-item label="浆槽温度" prop="temperature">
          <el-input v-model="form.temperature" placeholder="请输入浆槽温度" />
        </el-form-item>
        <el-form-item label="浆槽粘度" prop="viscosity">
          <el-input v-model="form.viscosity" placeholder="请输入浆槽粘度" />
        </el-form-item>
        <el-form-item label="浆槽PH值" prop="ph">
          <el-input v-model="form.ph" placeholder="请输入浆槽PH值" />
        </el-form-item>
        <el-form-item label="卷绕线速度" prop="windingspeed">
          <el-input v-model="form.windingspeed" placeholder="请输入卷绕线速度" />
        </el-form-item>
        <el-form-item label="张力调节" prop="tensionadjust">
          <el-input v-model="form.tensionadjust" placeholder="请输入张力调节" />
        </el-form-item>
        <el-form-item label="压浆辊压力" prop="force">
          <el-input v-model="form.force" placeholder="请输入压浆辊压力" />
        </el-form-item>
        <el-form-item label="预烘温度" prop="pretemp">
          <el-input v-model="form.pretemp" placeholder="请输入预烘温度" />
        </el-form-item>
        <el-form-item label="烘燥温度" prop="dryingtemp">
          <el-input v-model="form.dryingtemp" placeholder="请输入烘燥温度" />
        </el-form-item>
        <el-form-item label="要求" prop="request">
          <el-input v-model="form.request" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listGy_process, getGy_process, delGy_process, addGy_process, updateGy_process, exportGy_process } from "@/api/gongyi/gy_process";

export default {
  name: "Gy_process",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 工艺设计工艺表表格数据
      gy_processList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        machinetype: null,
        cylindernumber: null,
        beamopening: null,
        inklength: null,
        inkcolor: null,
        waxing: null,
        sizingpersent: null,
        moistureregain: null,
        elongation: null,
        temperature: null,
        viscosity: null,
        ph: null,
        windingspeed: null,
        tensionadjust: null,
        force: null,
        pretemp: null,
        dryingtemp: null,
        request: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询工艺设计工艺表列表 */
    getList() {
      this.loading = true;
      listGy_process(this.queryParams).then(response => {
        this.gy_processList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        machinetype: null,
        cylindernumber: null,
        beamopening: null,
        inklength: null,
        inkcolor: null,
        waxing: null,
        sizingpersent: null,
        moistureregain: null,
        elongation: null,
        temperature: null,
        viscosity: null,
        ph: null,
        windingspeed: null,
        tensionadjust: null,
        force: null,
        pretemp: null,
        dryingtemp: null,
        request: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加工艺设计工艺表";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getGy_process(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改工艺设计工艺表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateGy_process(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGy_process(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除工艺设计工艺表编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delGy_process(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有工艺设计工艺表数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportGy_process(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
